#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(SHADOW-FILE-SYSTEM, 1.0, shadowthecorder@gmail.com)
AC_CONFIG_SRCDIR([tools/gen_crc/main.cpp])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(SHADOW-FILE-SYSTEM,1.0)

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_LIBTOOL

# Checks for libraries.
# FIXME: Replace `main' with a function in `-levent_core':
AC_CHECK_LIB([event_core], [main])
# FIXME: Replace `main' with a function in `-levent_pthreads':
AC_CHECK_LIB([event_pthreads], [main])
# FIXME: Replace `main' with a function in `-ljson':
AC_CHECK_LIB([json], [main])
# FIXME: Replace `main' with a function in `-llog4cxx':
AC_CHECK_LIB([log4cxx], [main])
# FIXME: Replace `main' with a function in `-lmysql_conn_pool':
AC_CHECK_LIB([mysql_conn_pool], [main])
# FIXME: Replace `main' with a function in `-lmysqlclient_r':
AC_CHECK_LIB([mysqlclient_r], [main])
# FIXME: Replace `main' with a function in `-lsfs_client':
AC_CHECK_LIB([sfs_client], [main])
# FIXME: Replace `main' with a function in `-lsfs_cnf_svr_client':
AC_CHECK_LIB([sfs_cnf_svr_client], [main])
# FIXME: Replace `main' with a function in `-lsfs_data_svr_client':
AC_CHECK_LIB([sfs_data_svr_client], [main])
# FIXME: Replace `main' with a function in `-lsfs_meta_data_svr_client':
AC_CHECK_LIB([sfs_meta_data_svr_client], [main])
# FIXME: Replace `main' with a function in `-lsfs_name_svr_client':
AC_CHECK_LIB([sfs_name_svr_client], [main])
# FIXME: Replace `main' with a function in `-lsfs_util':
AC_CHECK_LIB([sfs_util], [main])
# FIXME: Replace `main' with a function in `-lsfw':
AC_CHECK_LIB([sfw], [main])
# FIXME: Replace `main' with a function in `-lz':
AC_CHECK_LIB([z], [main])

AC_CHECK_LIB(event_core, event_base_new, [], [
        echo "Error! You need to have event library around."
        exit -1
        ])
AC_CHECK_LIB(event_pthreads, evthread_use_pthreads, [], [
        echo "Error! You need to have event_pthread library around."
        exit -1
        ])
AC_CHECK_LIB(json, json_object_new_object, [], [
        echo "Error! You need to have json-c library around."
        exit -1
        ])
AC_CHECK_LIB(z, crc32, [], [
        echo "Error! You need to have z library around."
        exit -1
        ])
AC_CHECK_LIB(log4cxx, _init, [], [
        echo "Error! You need to have log4cxx library around."
        exit -1
        ])
AC_CHECK_LIB(mysqlclient_r, mysql_real_connect, [], [
        echo "Error! You need to have mysqlclient_r library around."
        exit -1
        ])


# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h netinet/in.h stdint.h sys/socket.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_HEADER_TIME
AC_STRUCT_TM

# Checks for library functions.
AC_HEADER_STDC
AC_FUNC_MKTIME
AC_FUNC_STAT
AC_CHECK_FUNCS([bzero localtime_r memset mkdir rmdir setlocale socket])

AC_PROG_RANLIB

AC_CONFIG_FILES([cnf_svr/client/src/Makefile
                 cnf_svr/client/test/Makefile
                 cnf_svr/server/src/Makefile
                 data_svr/client/src/Makefile
                 data_svr/client/test/Makefile
                 data_svr/server/src/Makefile
                 metadata_svr/client/src/Makefile
                 metadata_svr/client/test/Makefile
                 metadata_svr/server/src/Makefile
                 mysql_conn_pool/src/Makefile
                 mysql_conn_pool/test/Makefile
                 name_svr/client/src/Makefile
                 name_svr/client/test/Makefile
                 name_svr/server/src/Makefile
                 sfs_client/src/Makefile
                 sfs_client/test/Makefile
                 sfw/src/Makefile
                 sfw/test/Makefile
                 tools/gen_crc/Makefile
                 util/src/Makefile
                 ./Makefile
                 fuse/src/Makefile
                 util/test/Makefile])
AC_OUTPUT
